import java.util.List;

public class Leet4 {
    public static void main(String[] args) {
        Leet4 leet4 = new Leet4();
        System.out.println(leet4.findMedianSortedArrays(new int[]{1,3},new int[]{2}));
    }
    public double findMedianSortedArrays(int[] nums1, int[] nums2) {
        int l1 = 0;
        int l2 = 0;
        int[] all = new int[nums1.length + nums2.length];
        for (int i = 0; i < nums1.length + nums2.length; i++) {
            if (l1>= nums1.length||(l2< nums2.length&&nums1[l1]>nums2[l2])){
                all[i] = nums2[l2];
                l2++;
            }else {
                all[i] = nums1[l1];
                l1++;
            }
        }
        if (all.length%2==1)
            return all[all.length/2];
        else return Double.parseDouble(String.valueOf(all[all.length/2]+all[all.length/2-1]))/2;
    }
}
